package collection;

import java.util.ArrayList;
import java.util.Collection;

/**
 * 集合
 * java.util.CollectionDemo接口
 */
public class CollectionDemo {
    public static void main(String[] args) {
        Collection c =new ArrayList();
        /*
        boolean add(E e)
        向当前集合添加一个元素，元素成功添加后返回true
         */
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");

        System.out.println(c);

        int size= c.size();
        System.out.println("size"+size);

        /*
        boolean  isEmpty()
        判断当前集合是否为一个空集
         */
        boolean isEmpty =c.isEmpty();
        System.out.println("isEmpty"+isEmpty);

        /*
        void clear()
        清空集合
         */
        c.clear();
        System.out.println(c);
        System.out.println("size"+c.size());
        System.out.println("isEmpty"+c.isEmpty());
    }

}
